<?php

abstract class Kd_Data_Dcl_Base {

    protected $parameters = array();
    private $_dbDriver = NULL;

    protected function __construct() {

    }

    public function getDbDriver() {
        if (is_null($this->_dbDriver)) {
            $this->_dbDriver = Kd_Db_Factory::getDriver();
        }
        return $this->_dbDriver;
    }

    public function setDbDriver($value) {
        $this->_dbDriver = $value;
        return $this;
    }
    
    public function setDbTransaction(Kd_Db_Transaction $value = NULL) {
        $this->_dbDriver = $value->getDbDriver();
        return $this;
    }    

    public function getParameters() {
        return $this->parameters;
    }
    public function setParameters(array $value) {
        $this->parameters = $value;
        return $this;
    }

    public function addParameter() {
        $args = func_get_args();
        $cnt = func_num_args();
        if ($cnt == 2) {
            $this->parameters[$args[0]] = $args[1];
        } elseif ($cnt == 1 && is_array($args[0])) {
            $this->parameters = array_merge($this->parameters, $args[0]);
        }
        return $this;
    }

    public function reset() {
        return $this->resetParameters();
    }

    public function resetParameters() {
        $this->parameters = array();
        return $this;
    }

    public abstract function toSql();
}